package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.OrdersDto;
import com.itheima.reggie.entity.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

public interface OrdersMapper {

    /**
     * 添加订单
     * @param orders
     * @return
     */
    @Insert("insert into orders values (#{id},#{number},#{status},#{userId}," +
            "#{addressBookId},#{orderTime},#{checkoutTime},#{payMethod},#{amount}" +
            ",#{remark},#{phone},#{address},#{userName},#{consignee})")
    Integer addOrders(Orders orders);

    /**
     * 根据用户id查找订单
     * @param userId
     * @return
     */
    List<OrdersDto>findOrdersByUserId(@Param("userId") Long userId, @Param("number") String number, @Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);
}
